Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multiple schemas in config #193

Merged
merged 2 commits into from
Dec 31, 2023
Merged

Conversation

sonatard
Copy link
Collaborator

@sonatard sonatard commented Dec 31, 2023

failed to load schema: load local schema failed: loadLocalSchema: xxx.graphql:6: Undefined directive goField.
schema:
  - ./directive/*.graphql
  - ./scalar/*.graphql
  - ./resolver/*.graphql

Summary by CodeRabbit

  • Refactor
    • Improved configuration file handling for enhanced application performance.

Copy link

coderabbitai bot commented Dec 31, 2023

Walkthrough

The update to the configuration loading mechanism involves refining the handling of file lists, specifically schema filenames. There is a restructured approach to initializing and assigning file lists within the configuration function, which suggests an enhancement or fix in how the application manages its configuration files.

Changes

File(s) Summary of Changes
config/config.go Introduced initialization for StringList. Adjusted assignment of SchemaFilename to use the new StringList.

Poem

In the warren of code, where the digits do hop,
A change was made with a skip and a bop.
Files line up with a cheer, in a neat little crop,
"Hooray!" they exclaimed, "our schema's on top!" 🐇💻🎉

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share

Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • You can directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit-tests for this file.
  • You can tag CodeRabbit on specific lines of code or entire files in the PR by tagging @coderabbitai in a comment. Examples:
    • @coderabbitai generate unit tests for this file.
    • @coderabbitai modularize this function.
  • You can tag @coderabbitai in a PR comment and ask questions about the PR and the codebase. Examples:
    • @coderabbitai generate interesting stats about this repository from git and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit tests.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid.
    • @coderabbitai read the files in the src/scheduler package and generate README in the markdown format.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/coderabbit-overrides.v2.json

CodeRabbit Discord Community

Join our Discord Community to get help, request features, and share feedback.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 0

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c8ef9d8 and 5ad012d.
Files selected for processing (1)
  • config/config.go (2 hunks)
Additional comments: 1
config/config.go (1)
  • 169-184: > Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [139-181]

The changes to LoadConfig to support multiple schema files by using StringList seem correct and well-implemented. Ensure that all parts of the codebase that interact with cfg.SchemaFilename are updated to handle the StringList type correctly.

Verification successful

The search for usages of cfg.SchemaFilename within Go files has returned only the file config/config.go, which is the file that was modified in the pull request. This suggests that there are no other parts of the codebase using cfg.SchemaFilename that would be affected by the change to the StringList type. Therefore, no further action is required to update other parts of the codebase.

  • The changes to LoadConfig in config/config.go are consistent with the PR's objective to support multiple schema files.
  • The usage of cfg.SchemaFilename appears to be confined to config/config.go, indicating no immediate downstream effects on other parts of the codebase.
Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for usages of cfg.SchemaFilename to ensure they handle StringList type.
rg --type go 'cfg\.SchemaFilename' --files-with-matches

Length of output: 74

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Status

Actionable comments generated: 1

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between c8ef9d8 and a9f507c.
Files selected for processing (1)
  • config/config.go (2 hunks)
Additional comments: 2
config/config.go (2)
  • 139-142: The initialization of files as a StringList is correct and follows Go's idiomatic way of declaring and initializing variables.

  • 179-180: The assignment of files to cfg.SchemaFilename is correct and reflects the intent to support multiple schema files. This change should be verified to ensure that all parts of the application that use cfg.SchemaFilename can handle multiple values correctly.

Verification successful

Based on the usages of cfg.SchemaFilename in config/config.go, it is treated as an iterable, with range loops iterating over its elements. This supports the change to assign files (a StringList) to cfg.SchemaFilename, indicating that the application is expected to handle multiple schema filenames correctly.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the application correctly handles multiple schema files.
# This script should be run in the root of the repository.
rg --type go 'cfg.SchemaFilename' --files-with-matches

Length of output: 71



Script:

#!/bin/bash
# Check the usage of 'cfg.SchemaFilename' within 'config/config.go' to determine if it's used as a single string or a list.
rg --type go 'cfg.SchemaFilename' config/config.go

Length of output: 275

Comment on lines 169 to 183
}
}

files := StringList{}
for _, m := range matches {
if !files.Has(m) {
files = append(files, m)
}
}

cfg.SchemaFilename = files
}

cfg.SchemaFilename = files

models := make(config.TypeMap)
if cfg.Models != nil {
models = cfg.Models
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: This review was outside the patches, so it was mapped to the patch with the greatest overlap. Original lines [140-176]

The logic for handling glob patterns and appending unique file paths to files appears correct. However, ensure that the StringList.Has method is efficient for larger sets of schema files, as it currently has O(n) complexity for each check.

// Consider using a map for efficient lookups if the number of schema files is large.

@Yamashou Yamashou merged commit 484c08b into Yamashou:master Dec 31, 2023
1 check passed
@sonatard sonatard deleted the fix-schema branch June 5, 2024 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants